Veery testing code=yes todo (add to couchdb the ability to generate a list of tag names and their counts, if possible. two display options would be nice: by tag name and count. like with Grebe and Junco. need the couchdb equivalent to count(*) and group_by in SQL.) Read a Single Post ================== Grab my profile page, which has the _id of "profile". Currently, the default is to return HTML only. curl http://veeryapiperl.soupmode.com/api/posts/profile This produces the same thing. curl http://veeryapiperl.soupmode.com/api/posts/profile/?text=html { "status":200, "description":"OK", "post": { "post_type":"article", "title":"Profile", "slug":"profile", "author":"MrX", "created_at":"2015/02/11 14:54:49", "updated_at":"2015/04/21 15:56:10", "word_count":16, "reading_time":0, "html":"\n

Profile

\n\n

my profile page that contains nothing because i want to blend into the background.

\n\n

\"\"

\n" } } Get the markup. The _rev is returned for updating. To include the _rev info, the user's logged-in info must be submitted on the query string with the text=markup. This will not include the _rev info. curl http://veeryapiperl.soupmode.com/api/posts/profile/?text=markup To include _rev info: curl http://veeryapiperl.soupmode.com/api/posts/profile/?text=markup \&author=MrX\&session_id=50ff8f05c0f5d95aabbe7c5d810340c1 { "status":200, "description":"OK", "post": { "_rev":"3-97b3bc9434ea346a49b7709c6dd1e9fd", "post_type":"article", "title":"Profile", "slug":"profile", "markup":"# Profile\r\n\r\nmy profile page that contains nothing because i want to blend into the background.\r\n\r\n![](http://farm4.static.flickr.com/3156/2614312687_3fe4cae2a9_o.jpg)" } } Get the markup and the HTML. curl http://veeryapiperl.soupmode.com/api/posts/profile/?text=full { "status":200, "description":"OK", "post": { "post_type":"article", "title":"Profile", "slug":"profile", "author":"MrX", "created_at":"2015/02/11 14:54:49", "updated_at":"2015/04/21 15:56:10", "word_count":16, "reading_time":0, "markup":"# Profile\r\n\r\nmy profile page that contains nothing because i want to blend into the background.\r\n\r\n![](http://farm4.static.flickr.com/3156/2614312687_3fe4cae2a9_o.jpg)", "html":"\n

Profile

\n\n

my profile page that contains nothing because i want to blend into the background.

\n\n

\"\"

\n" } } Get the Homepage Stream of Posts ================================ curl http://veeryapiperl.soupmode.com/api/posts Page 3 of the stream of posts curl http://veeryapiperl.soupmode.com/api/posts/?page=3 { "status":200, "description":"OK", "posts": [ { "post_type":"article", "slug":"test-multimarkdown", "author":"MrX", "updated_at":"2015/04/30 01:57:55", "formatted_updated_at":"Apr 30, 2015 01:57:55 Z", "reading_time":0, "more_text_exists":1, "tags":[], "text_intro":" test multimarkdown - Here is as example of [table][simple_table] followed by a more complex example from the documentation simple_table \tFirst Header \tSecond Header \tThird Header \t \tFirst row \tData \tVery long data entry \t \tSecond row \tCell \tCell \t Prototype table ..." }, { "post_type":"article", "slug":"info", "author":"MrX", "updated_at":"2015/04/29 21:56:57", "formatted_updated_at":"Apr 29, 2015 21:56:57 Z", "reading_time":0, "more_text_exists":0, "tags":["scaup","blogging"], "text_intro":"Info - Minimal web publishing tool. Formatting can be created by using markup syntax from Markdown, MultiMarkdown, Textile, and HTML. Tech used: Ubuntu Nginx FastCGI Perl HTML::Template CouchDB Memcached Elasticsearch #scaup #blogging" } ] } Stream of posts from a search request ===================================== ** Currently, searches are done with GET requests. Should this change only to POST requests, or should POST requests be added to the GET requests? String which could be comprised of one or more words ---------------------------------------------------- Search on "beer" curl http://veeryapiperl.soupmode.com/api/searches/string/beer Search on "craft beer" curl http://veeryapiperl.soupmode.com/api/searches/string/craft%20beer ** Elasticsearch notes: it seems that when entering a text string surrounded by double quotes, then an exact string match is conducted by Elasticsearch. When a plus sign separates words, then it seems that an 'OR' Boolean search is conducted. I have not yet exploited the full power of Elasticsearch, such as creating patterns. Currently, I'm using only its basic functionality. Tag search ---------- curl http://veeryapiperl.soupmode.com/api/searches/tag/toledo Returned JSON for search on tag field for "beer" : { "status":200, "description":"OK", "next_link_bool":0, "posts":[ { "author":"MrX", "reading_time":1, "text_intro":" Black Cloister Feb 26 2015 notes - Feb 26, 2015 - Toledo Blade - Black Cloister Brewing Co. taps opening date The story is part of a new Blade column, called \"Raise a Glass.\" ", "slug":"black-cloister-feb-26-2015-notes", "formatted_updated_at":"Feb 26, 2015 16:14:32 Z", "post_type":"article", "more_text_exists":1, "tags":["toledo","beer","brewery"], "updated_at":"2015/02/26 16:14:32" }, { "author":"MrX", "reading_time":1, "text_intro":"Jan 15, 2015 insights from Tom at Titgemeier's. - I visited Titgemeier's this morning to buy bird seed, honey, and a bottle capper. I broke our capper last night. I chatted with Tom for a while. We definitely missed a good Glass City Mashers meeting last Thursday. Chris spoke. He's the owne ...", "slug":"jan-15-2015-insights-from-tom-at-titgemeiers", "formatted_updated_at":"Feb 25, 2015 13:27:01 Z", "post_type":"article", "more_text_exists":1, "tags":["beer","business","toledo"], "updated_at":"2015/02/25 13:27:01" } ] } todo : Add: curl http://veeryapiperl.soupmode.com/api/tags/beer to simplify tag searches. This exists with Grebe, but the "tags" API in Grebe performs other duties too. todo : Grebe has AND and OR Boolean options with tag searches. Does not exist with Scaup, and I may add advanced searching functions to Veery at a later date. Doing a string search on a hashtag ------------------------------------- curl http://veeryapiperl.soupmode.com/api/searches/string/%23scarf Login - creating and sending the no password login link ======================================================= curl -X POST -H "Content-Type: application/json" --data '{ "email" : "x@x.com", "url" : "http://veeryclientperl/nopwdlogin"}' http://veeryapiperl.soupmode.com/api/users/login { "status":200, "session_id_rev":"1-073335f570d5cf202bac424e0b05cb9b", "system_message":"A new login link has been created and sent.", "user_message":"Creating New Login Link", "description":"OK" } The 'session_id_rev' name=value is only included in the returned JSON when 'debug_mode' equals '1' in the API's YAML config file. Login - activating the no password login link ============================================= This will create the user's login session. curl http://veeryapiperl.soupmode.com/api/users/login/?rev=12345 Returned JSON: { "author_name":"MrX", "session_id":"50ff8f05c0f5d95aabbe7c5d810323c8", "status":200, "description":"OK" } Get User Info ============= The submitted author name is case-sensitive, for now, with regards to the lookup within CouchDB. Useful to determine if the user is logged-in. curl http://veeryapiperl.soupmode.com/api/users/MrX {"is_logged_in":0,"status":200,"name":"MrX","type":"author","description":"OK"} If valid login, the additional info is returned: curl http://veeryapiperl.soupmode.com/api/users/MrX/?author=MrX\&session_id=50ff8f05c0f5d95aabbe7c5d810340c1 { "_id" : "abbe7c5d810006f8", "_rev" : "12-90b9a5ae6c32d", "type" : "author", "name" : "MrX", "email" : "mrx@mrx.xyz", "current_session_id" : "5aabbe7c5d8103411c" } Updating author's info ====================== At the moment, only email address can be updated because little else is stored within the author's doc that can be modified. curl -X PUT -H "Content-Type: application/json" --data '{"author": "MrX", "session_id": "5aabbe7c5d810346cb", "id": "2384849494", "rev": "45454554", "new_email" : "new@new.com", "old_email" : "old@old.com"}' http://veeryapiperl.soupmode.com/api/users { "status":200, "description":"OK" } Create a New Post ================= curl -X POST -H "Content-Type: application/json" --data '{"author": "MrX", "session_id": "5012344558568686", "submit_type": "Post", "markup": "h1. 13may2015 2059\n\n test post from Perl Veery API"}' http://veeryapiperl.soupmode.com/api/posts Returned JSON { "html":"\n

13may2015 2059

\n\n

test post from Perl Veery API

", "status":200, "rev":"1-f6eaf40f56dbb2ccc07919535f891ee1", "post_id":"13may2015-2059", "description":"OK" } Update a Post ============= Preview ------- curl -X PUT -H "Content-Type: application/json" --data '{"author": "MrX", "session_id": "50ff8f05c0f5d95aabbe7c5d810323c8", "rev": "50ff8f05c0f5d95aabbe7c5d810323c8", "post_id": "13may2015-2059", "submit_type": "Preview", "markup": "h1. 13may2015 2059\n\n Updated - test post from Perl Veery API"}' http://veeryapiperl.soupmode.com/api/posts { "html":"\n

13may2015 2059

\n\n

Updated - test post from Perl Veery API

", "status":200, "description":"OK" } Wrong Rev info Submitted on Update ---------------------------------- { "status":"400", "system_message":"Invalid rev information provided.", "user_message":"Unable to update post.", "description":"Bad Request" } Not logged in when trying to create or update content ----------------------------------------------------- { "status":"400", "system_message":"You are not logged in.", "user_message":"Unable to peform action.", "description":"Bad Request" } Successfully updating a post ---------------------------- curl -X PUT -H "Content-Type: application/json" --data '{"author": "MrX", "session_id": "50ff8f05c0f5d95aabbe7c5d810323c8", "rev": "1-f6eaf40f56dbb2ccc07919535f891ee1", "post_id": "13may2015-2059", "submit_type": "Update", "markup": "h1. 13may2015 2059\n\n Updated - test post from Perl Veery API"}' http://veeryapiperl.soupmode.com/api/posts Returned JSON: { "html":"\n

13may2015 2059

\n\n

Updated - test post from Perl Veery API

", "title": "13may2015 2059", "status":200, "rev":"2-43eb2b79a7d58de0e3678387cfd1e5c9", "description":"OK" } Deleting and Undeleting a post ============================== Change the value for 'action' accordingly. curl http://veeryapiperl.soupmode.com/api/posts/13may2015-2059/?action=undelete\&author=MrX\&session_id=50ff8f05c0f5d95aabbe7c5d810340c1 Returned JSON { "status":200, "description":"OK" } Show list of deleted posts ========================== curl http://veeryapiperl.soupmode.com/api/posts/?deleted=yes\&author=Mrx\&session_id=50ff8f05c0f5d95aabbe7c5d810340c1 { "status":200, "posts":[ { "post_type":"note", "slug":"test-post-mar-6-2015-0901", "title":"test post mar 6, 2015 - 0901" }, { "post_type":"article", "slug":"test-post-2mar2015", "title":"%20Test%20post%202Mar2015%0A%0Acreated%20within%20the%20javascript%20editor.%0A" }, ], "description":"OK" } Logging out =========== curl http://veeryapiperl.soupmode.com/api/users/logout/?author=MrX\&session_id=50ff8f05c0f5d95aabbe7c5d810340c1 { "status":200, "description":"OK", "logged_out":"true" } If unsuccessful for some reason: { "status":"400", "description":"Bad Request", "user_message":"Unable to logout.", "system_message":"Invalid info submitted." } ====================================== ====================================== Three "doc" types. If this was SQL, these would be three separate tables. Author (i changed and decided to set the _id to the author name, therefore the 'name' field may not be needed, but i'll leave it for now.) { "_id" : "MrX", "_rev" : "1-435be1729c60657a333adee6e190869d", "type" : "author", "name" : "MrX", "email" : "mrx@mrx.com", "current_session_id" : "50ff8f05c0f5d95aabbe7c5d81026436" } Session ID Description { "_id" : "50ff8f05c0f5d95aabbe7c5d81026c1a", "_rev" : "2-91027f061be5f73ccb9784d1fff8210e", "type" : "session_id", "created_at" : "2015/04/17 18:53:03", "updated_at" : "2015/04/17 18:53:03", "status" : "active" } Description for post type of "article" or "note" { "_id" : "test-post", "_rev" : "4-ad0c0316a32ac4b217431127130fd516", "type" : "post", "post_type" : "article", "title" : "Test post", "slug" : "test-post", "author" : "MrX", "created_at" : "2015/04/17 13:37:35", "updated_at" : "2015/04/17 14:09:30", "word_count" : 432, "reading_time" : 2, "text_intro" : "paragraph of text", "more_text_exists" : 1, "markup" : "entire markup of the post", "html" : "entire post formatted in HTML", "tags" : ["scaup","blogging","couchdb"], "post_status" : "public" }